/**
 * MainActivity.java
 */
package com.krui.iweibo.ui;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;

import com.krui.iweibo.R;

/**
 * MainActivity.java
 * @author krui
 * 2012-6-27 上午07:05:04
 * 
 */
public class MainActivity extends TabActivity{
	
	
	private static final String HOME_TAB="home"; 
	private static final String USER_TAB="user"; 
	private static final String MSG_TAB="msg"; 
	private static final String SEARCH_TAB="search"; 
	private static final String MORE_TAB="more"; 
	
	private TabHost tabHost;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		this.setContentView(R.layout.maintabs);
		
		tabHost = getTabHost();
		
		TabHost.TabSpec homeSpec = tabHost.newTabSpec(HOME_TAB).setIndicator(HOME_TAB).setContent(new Intent(this,HomeActivity.class));
		TabHost.TabSpec msgSpec=tabHost.newTabSpec(MSG_TAB).setIndicator(MSG_TAB).setContent(new Intent(this,MsgActivity.class));
		TabHost.TabSpec userSpec=tabHost.newTabSpec(USER_TAB).setIndicator(USER_TAB).setContent(new Intent(this,UserActivity.class));
		TabHost.TabSpec searchSpec=tabHost.newTabSpec(SEARCH_TAB).setIndicator(SEARCH_TAB).setContent(new Intent(this,SearchActivity.class));
		TabHost.TabSpec moreSpec=tabHost.newTabSpec(MORE_TAB).setIndicator(MORE_TAB).setContent(new Intent(this,MoreActivity.class));
		    
		    tabHost.addTab(homeSpec);
		    tabHost.addTab(userSpec);
		    tabHost.addTab(msgSpec);
		    tabHost.addTab(searchSpec);
		    tabHost.addTab(moreSpec);
		    
		    
		    RadioGroup radioGroup =  (RadioGroup) this.findViewById(R.id.main_radio);
		    
		    radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
				{
					
					public void onCheckedChanged(RadioGroup group, int checkedId)
					{
						
						switch (checkedId)
						{
						case R.id.radio_button0:
							tabHost.setCurrentTabByTag(HOME_TAB);
							break;
							
						case R.id.radio_button1:
							tabHost.setCurrentTabByTag(MSG_TAB);
							break;
							
						case R.id.radio_button2:
							tabHost.setCurrentTabByTag(USER_TAB);
							break;
							
						case R.id.radio_button3:
							tabHost.setCurrentTabByTag(SEARCH_TAB);
							break;
							
						case R.id.radio_button4:
							tabHost.setCurrentTabByTag(MORE_TAB);
							break;

						default:
							break;
						}
					}
				});
	}

}
